<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1a5a5a5/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1, minimum-scale=1, user-scalable=no, maximum-scale=1,width=device-width">
<meta name="viewport" content="width=device-width, user-scalable=no">
<!-- uc强制竖屏 -->
<meta name="screen-orientation" content="portrait">
<!-- QQ强制竖屏 -->
<meta name="x5-orientation" content="portrait">

<title></title>
<link rel="icon" type="images/png" href="" />
<meta name="keywords" content="" />
<meta name="description" content="" />

<!-- 功能样式 -->
<link type="text/css" rel="stylesheet"  href="css/style.css"/><!-- 公用样式 -->
<link type="text/css" rel="stylesheet"  href="css/index.css"/><!-- 首页样式 -->

<script src="js/jquery-1.8.3.min.js"></script><!-- 公用 -->
<!-- 功能样式 -->

<!--[if lt IE 9]>
<script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script>
<![endif]-->

</head>
 
<body>

<!-- 搜索 -->
<div id="search" class="clearfix">
	<a class="prev fl" href="javascript:history.go(-1);" title="后退">&lt;</a>
	<div class="head fl">
    	购物车
    </div>
</div>
<!-- 搜索 -->

<!-- 内容 -->
<div id="switch">
<div class="empty-cart">
    <div class="cartlogo">空的购物车</div>
    <p class="message">没有宝贝哦，不如去添加宝贝</p>
    <ul class="carta">
    	<li><a href="shop.html">返回购物</a></li>
    </ul>
  </div>
</div>
<!-- 内容 -->

<!-- javascript -->
<script type="text/javascript">
//购物车
$(document).ready (function ()
{
	var pl = $("i:last");
	var reg = /(.*[\:\：]\s*)([\+\d\.]+)(\s*元)/g;
	$ (".sy_minus").click (function ()
	{
		var me = $ (this), txt = me.next (":text"), pc = me.closest("p");
		var val = parseFloat (txt.val ());
		val = val < 1 ? 1 : val;
		txt.val (val - 1);
		var price = parseFloat (pc.prev("p").text().replace(reg,'$2')) * txt.val ();
		pc.next("p").text (pc.next("p").text().replace(reg, "$1" + price + "$3"));
		var sum = 0;
		$(".p_num").next("p").each(function (i, dom)
		{
			sum += parseFloat ($(this).text().replace(reg, "$2"));
		});
		pl.text(pl.text().replace(reg, "$1" + sum + "$3"));
	});
	
	$(".sy_plus").click (function ()
	{
		var me = $ (this), txt = me.prev (":text"), pc = me.closest("p");
		var val = parseFloat (txt.val ());
		txt.val (val + 1);
		var price = parseFloat (pc.prev("p").text().replace(reg,'$2')) * txt.val ();
		pc.next("p").text (pc.next("p").text().replace(reg, "$1" + price + "$3"));
		var sum = 0;
		$(".p_num").next("p").each(function (i, dom)
		{
			sum += parseFloat ($(this).text().replace(reg, "$2"));
		});
		pl.text(pl.text().replace(reg, "$1" + sum + "$3"));
	});
})[0].onselectstart = new Function ("return false");
</script>
<!-- javascript -->
</body>
</html>
